package cn.wolfcode.p2p.enums;

/**
 * 错误码
 */
public enum ErrorCode {

    //构造器
    LOGININFO_NICKNAME_NULL("100", "昵称不可为空"),
    LOGININFO_NICKNAME_LENGTH_ERROR("101", "昵称长度{0}-{1}位"),
    LOGININFO_USERNAME_NULL("102","手机号不为空"),
    LOGININFO_USERNAME_LENGTH_ERROR("108","请输入{0}位的手机号"),
    LOGININFO_USERNAME_EXIST_ERROR("103","手机号已被注册" ),
    LOGININFO_USERNAME_FORMAT_ERROR("104","手机号格式有误" ),
    LOGININFO_PASSWORD_LENGTH_ERROR("105","密码长度{0}-{1}位" ),
    LOGININFO_CONFIRM_PASSWORD_EQUALS_ERROR("106","两次密码输入不一致" ),
    LOGININFO_VERIFYCODE_LENGTH_ERROR("107","验证码长度{0}位" ),
    LOGININFO_VERIFYCODE_NULL("109","验证码不可为空" );


    private final String code;
    private final String message;

    ErrorCode(String code, String message) {
        this.code = code;
        this.message = message;
    }

    public String getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }

    //拼接错误信息和错误码
    public String getErrorMessage() {
        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append(this.getMessage()).append("[").append(this.getCode()).append("]");
        return stringBuilder.toString();
    }
}
